<?php defined('IN_YuLin') || exit('NO PERMIT!'); ?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>文章信息 - 后台管理系统</title>
        <meta name="renderer" content="webkit|ie-comp|ie-stand">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
        <link rel="stylesheet" type="text/css" href="static/css/font-awesome.min.css"/>
        <link rel="stylesheet" href="static/css/style.css">
    </head>
    <body>
        <div class="subnav">
            <a href="">首页</a> &gt; <a href="">客户管理</a> &gt; 网站公告
        </div>
        
        <div class="main-inner">
            <div class="x-body">
                <div class="tablefilter">
                    <div class="tablebutton">
                        <a href="?m={$m}&c={$c}&a=add&id=3" class=""><i class="fa fa-plus"></i>新增</a>
                        <a class="chooseAll"><i class="fa fa-check"></i>全选</a>
                        <a class="delete"><i class="fa fa-trash"></i>删除</a>      
                    </div>
                </div>

                <table class="layui-table">
                    <thead>
                        <tr>
                            <th>选择</th>
                            <th>标题</th>
                            <th>内容简略</th>
                            <th>发布时间</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody id="datalist">
                        {loop $data as $val}
                            <tr>
                                <td>
                                    <input type="checkbox" value="{$val['id']}" />
                                </td>
                                <td>{$val['title']}</td>
                                <td>{CutStr(strip_tags($val['content']),60)}</td>
                                <td>{date('Y-m-d H:i:s',$val['dateline'])}</td>
                                <td><a href="?m={$m}&c={$c}&a=edit&id={$val['id']}">编辑</a></td>
                              
                            </tr>
                        {/loop}
                    </tbody>
                </table>
                <div class="layui-clear">
                    <div id="pages" class="layui-laypage right">{$multi}</div>
                </div>
            </div>
        </div>
        <script type="text/javascript" src="static/js/jquery.min.js"></script>
        <script type="text/javascript">
            $(function(){
                var oBtn = false;
                $(".chooseAll").on('click',function(){
                    if(!oBtn){
                        $("input[type=checkbox]").prop('checked',true);
                        oBtn = true;
                    }else{
                        $("input[type=checkbox]").prop('checked',false);
                        oBtn = false;
                    }
                })

                $(".delete").on('click',function(){
                    var ids = [];
                    $("input[type=checkbox]:checked").map(function(){
                        ids.push($(this).val());
                    });
                    if(!ids.length){
                        alert('当前没有可操作的元素');return;
                    }
                    $.ajaxSetup({async:false});
                    $.post("?m=user&c=notice&a=delete",{ids:ids},function(res){
                        res = eval('('+res+')');
                        alert(res.msg);
                        window.location.reload();
                    });
                });
            })
        </script>
    </body>
</html>
